package com.ptswitch.material.model.contract;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.validation.constraints.Size;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.hibernate.validator.constraints.NotBlank;
import org.hxzon.project.BaseEntity;

@Entity
public class ContractSupplier extends BaseEntity implements Comparable<ContractSupplier> {

    private static final long serialVersionUID = 5156788179539859892L;

    @Column(columnDefinition = DefineVarchar2048)
    @Size(max = DefineSize2048)
    @NotBlank
    private String name;

    @Column(columnDefinition = DefineVarchar2048)
    @Size(max = DefineSize2048)
    private String remark;

    // get and set

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String toString() {
        return this.name;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof ContractSupplier)) {
            return false;
        }
        ContractSupplier other = (ContractSupplier) o;
        return new EqualsBuilder().append(this.name, other.getName()).isEquals();
    }

    public int hashCode() {
        return new HashCodeBuilder().append(this.name).toHashCode();
    }

    public int compareTo(ContractSupplier o) {
        return this.name.compareTo(o.getName());
    }
}
